package ${serviceTestUrl};

import com.alibaba.fastjson.JSON;
import ${entityUrl}.${entityName};
import ${serviceUrl}.${entityName}Service;
import com.baoyuan.crm.handler.DataSourceExecute;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ${serviceTestName} {

    @Autowired
    private ${entityName}Service service;

    @Test
    public void test_findEntityById() {
        Long id = 1L;
        ${entityName} entity = service.findEntityById(id);
        System.out.println("findEntityById: " + JSON.toJSONString(entity));
    }


    @Test
    public void test_save() {
        Long operatorId = 1L;
        Long tenantId = 1L;
        ${entityName} param = new ${entityName}();
        Date now = new Date();
        <#list cis as ci>
            <#if ci.property == "isDeleted">
        param.setIsDeleted(Boolean.FALSE);
            <#elseif ci.property == "tenantId">
        param.${ci.propertySetMethod}(${ci.property});
            <#elseif ci.property == "creatorId" || ci.property == "createId" || ci.property == "updateId" || ci.property == "updatorId">
        param.${ci.propertySetMethod}(operatorId);
            <#elseif ci.property == "createTime" || ci.property == "updateTime">
        param.${ci.propertySetMethod}(now);
            <#elseif ci.property == "id">
        //
            <#else >
        // param.${ci.propertySetMethod}(${ci.property}); // 为该字段填充 测试值
            </#if>
        </#list>
        Long id = service.saveEntity(param);
        System.out.println("id: " + id);
        // TODO
    }
}